From b0313c7bcf7bf95bad050f2528a5586eb1a48480 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 29 Oct 2014 17:31:15 +0100 Subject: [PATCH] wayland: Emit GDK_OWNER_CHANGE events around wl_data_offer changes This way the upper GtkClipboard code emits correctly ::owner-change when receiving these events. --- gdk/wayland/gdkdevice-wayland.c | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 6716c01b69..b176450ccd 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -538,6 +538,39 @@ _gdk_wayland_device_get_keymap (GdkDevice *device) return GDK_WAYLAND_DEVICE (device)->device->keymap; } +static void +emit_selection_owner_change (GdkWindow *window, + GdkAtom atom) +{ + GdkEvent *event; + + event = gdk_event_new (GDK_OWNER_CHANGE); + event->owner_change.window = g_object_ref (window); + event->owner_change.owner = NULL; + event->owner_change.reason = GDK_OWNER_CHANGE_NEW_OWNER; + event->owner_change.selection = atom; + event->owner_change.time = GDK_CURRENT_TIME; + event->owner_change.selection_time = GDK_CURRENT_TIME; + + gdk_event_put (event); + gdk_event_free (event); +} + +static void +emit_selection_owner_change_forall (GdkAtom atom) +{ + GdkDisplay *display = gdk_display_get_default (); + GdkScreen *screen = GDK_WAYLAND_DISPLAY (display)->screen; + GList *windows, *l; + + windows = gdk_screen_get_toplevel_windows (screen); + + for (l = windows; l; l = l->next) + emit_selection_owner_change (l->data, atom); + + g_list_free (windows); +} + static void data_device_data_offer (void *data, struct wl_data_device *data_device, @@ -545,6 +578,8 @@ data_device_data_offer (void *data, { GdkWaylandDeviceData *device = (GdkWaylandDeviceData *)data; gdk_wayland_selection_set_offer (device->display, _offer); + + emit_selection_owner_change_forall (gdk_atom_intern_static_string ("GdkWaylandSelection")); } static void @@ -587,6 +622,8 @@ data_device_enter (void *data, _gdk_wayland_drag_context_emit_event (device->drop_context, GDK_DRAG_ENTER, GDK_CURRENT_TIME); gdk_wayland_selection_set_offer (device->display, offer); + emit_selection_owner_change (dest_window, + gdk_atom_intern_static_string ("GdkWaylandSelection")); } static void @@ -671,6 +708,7 @@ data_device_selection (void *data, G_STRFUNC, wl_data_device, offer); gdk_wayland_selection_set_offer (device->display, offer); + emit_selection_owner_change_forall (gdk_atom_intern_static_string ("CLIPBOARD")); } static const struct wl_data_device_listener data_device_listener = { -- 2.30.2